Skip to content

Add missing stddef.h include to lib_export.h#4952

Open
stertl wants to merge 1 commit into
bytecodealliance:mainfrom
siemens:dev/fix_lib_export_includes
Open

Add missing stddef.h include to lib_export.h#4952
stertl wants to merge 1 commit into
bytecodealliance:mainfrom
siemens:dev/fix_lib_export_includes

Conversation

@stertl
Copy link
Copy Markdown

@stertl stertl commented May 22, 2026

The core/iwasm/include/lib_export.h misses an include of <stddef.h>, which is required for the definition of NULL.

Testing

// lib_export_test.c
#include <stdint.h>
#include "lib_export.h"

struct WASMExecEnv;
typedef struct WASMExecEnv *wasm_exec_env_t;

int foo_wrapper(wasm_exec_env_t exec_env) {
  (void)exec_env;
  return 42; }

static NativeSymbol native_symbols[] = {EXPORT_WASM_API_WITH_SIG2(foo, "()i")};

uint32_t get_native_lib(char **p_module_name, NativeSymbol **p_native_symbols)
{
  *p_module_name = "env";
  *p_native_symbols = native_symbols;
  return sizeof(native_symbols) / sizeof(NativeSymbol);
}
$ clang -shared -I ./core/iwasm/include -o lib_export_test.so lib_export_test.c
lib_export_test.c:6:41: error: use of undeclared identifier 'NULL'
static NativeSymbol native_symbols[] = {EXPORT_WASM_API_WITH_SIG2(foo, "()i")};
                                        ^
./core/iwasm/include/lib_export.h:39:53: note: expanded from macro 'EXPORT_WASM_API_WITH_SIG2'
    { #symbol, (void *)symbol##_wrapper, signature, NULL }
                                                    ^
lib_export_test.c:12:16: error: invalid application of 'sizeof' to an incomplete type 'NativeSymbol[]' (aka 'struct NativeSymbol[]')
  return sizeof(native_symbols) / sizeof(NativeSymbol);
               ^~~~~~~~~~~~~~~~
2 errors generated.

- needed for definition of NULL
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant